import {
  ModalForm,
  ProFormSelect,
} from '@ant-design/pro-components';
import { useModel } from '@umijs/max';
import React, { PropsWithChildren } from 'react';

interface UpdateFormProps {
  clrCategoryEnum: Map<number, { text: string }>;
  children: any;
  echoRecord:API.ClassInfo
}
const BeginForm: React.FC<PropsWithChildren<UpdateFormProps>> = ({
  clrCategoryEnum,
  children,
  echoRecord,
}) => {
  const {beginHandler } = useModel('Class.model', (model) => ({
    beginHandler: model.beginHandler,
  }));

  return (
    <ModalForm<API.Class_Begin_Body>
      trigger={children}
      title="选择教室"
      autoFocusFirstInput
      submitTimeout={2000}
      modalProps={{ destroyOnClose: true }}
      onFinish={async (values) => {
       const success = await beginHandler({
          ...values,
          cls_id: echoRecord.cls_id,
       });
       return success;
      }
      }
    >
      <ProFormSelect
        name="cls_clsr_id"
        label="教室名称"
        placeholder="请选择教室"
        valueEnum={clrCategoryEnum}
        rules={[{ required: true, message: '教室为必选项' }]}
      />
    </ModalForm>
  );
};

export default BeginForm;
